<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
if(!isset($_SESSION['adminuserid']))
{
	header("location:index.php?msg=logfirst");
	die();
}

//DELETE record from database
if(isset($_REQUEST['a']) && trim($_REQUEST['a'])==3)
{
	if(isset($_REQUEST['intid']) && trim($_REQUEST['intid']!=""))
	{	
		$id =  $_REQUEST['intid'];
		$sql= "DELETE FROM `tblorders` WHERE `intid` ='$id'";
		$query1 = mysql_query($sql);
		
		header("location:orderstatus.php?msg=del");
		die();
	}
}

?>
<?php include("inc/header.php");?>
<body>



<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="middlebackground">
  <tr>
    <td valign="top" align="center"><?php include(INC."top.php");?></td>
  </tr>
  <tr valign="top">
    <td align="center"><table width="72%" border="0" cellpadding="2" cellspacing="2" class="border">
      <tr>
        <td colspan="6" class="bg1">Customer Order Status...</td>
        </tr>
      <tr align="center" class="tblbg3">
        <td><strong>Customer</strong></td>
        <td><strong>Order Status </strong></td>
		<td><strong><?php 
			if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphaasc')
			{
		?>
		<a  class="ab1" href="orderstatus.php?sort=alphadesc">Date&nbsp;<img src="../images/down.gif" border="0" /></a>
		<?php 
			}
			else if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphadesc')
			{
		?><a class="ab1" href="orderstatus.php?sort=alphaasc">Date&nbsp;<img src="../images/up.gif" border="0" /></a>
		<?php }
			else
			{
			 ?>
			 <a class="ab1" href="orderstatus.php?sort=alphadesc">Date</a>
			 <?php
		 }?> </strong></td>
		<td><strong>Order Total </strong></td>
		<td><strong>Order Details</strong></td>
		<td><strong>Delete </strong></td>
      </tr>
	  
	  <?php
	  	
			
				$tablename="tblorders";
				$per_page_keywords= "intcustomerid!=''";
				$per_page_sorts= "";			
				include("system/paging.inc.php");
			
			if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphaasc')
			{
			$sql_select = "select * from  ".$tablename."
			where ".$per_page_keywords." ORDER BY `dtfinished` ASC			
			Limit ".($page_no*$row_per_page).",".$row_per_page; 
			}
			else if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphadesc')
			{
			$sql_select = "select * from  ".$tablename."
			where ".$per_page_keywords." ORDER BY `dtfinished` DESC			
			Limit ".($page_no*$row_per_page).",".$row_per_page; 
			}
			else
			{
			$sql_select = "select * from  ".$tablename."
			where ".$per_page_keywords."			
			Limit ".($page_no*$row_per_page).",".$row_per_page; 
			}
			$sql = $obj_db->select($sql_select);
			if($sql)
			{
			
				for($j=0;$j<count($sql);$j++)
				{ 
		  ?>
		 
	    <tr align="center" class="<?php echo ($j%2==0)?"Hrnormal":"Hralter"; ?>" onMouseOver="this.className='Hrhover';" onMouseOut="this.className='<?php echo ($j%2==0)?"Hrnormal":"Hralter"; ?>';">
        
        <?php		
		$sql1 = "SELECT * FROM tblcustomers WHERE `intcusid` =".$sql[$j]['intcustomerid'];
		$res=$obj_db->select($sql1);
		
		
		if($sql1)
			{			
				for($j1=0;$j1<count($res);$j1++)
				{
				?>
				
					<td><?php echo $res[$j1]['varcustfname']."&nbsp;&nbsp;".$res[$j1]['varcustlname'];?></td>
				<?php
				}
			} ?> 
        <td><?php		
				$sql_select2 = "select *
				from `tblorderstatus` 
				where  intid=".$sql[$j]['intcurrentorderstatus']; 
				$sql2 = $obj_db->select($sql_select2);
				if($sql2)
				{	 
					echo $sql2[0]['varstatus'];		
				}
			?></td>
		<td><?php 
		
			echo $sql[$j]['dtfinished']; 
		
		?></td>
		<td>$<?php echo $sql[$j]['deccurrencyvalue']; ?></td>
		
		<td><a Title='Click here for Order Details' href="orders.php?cust=<?php = $sql[$j]['intcustomerid'];?>" class="fntstyle1">Order Details</a></td>
		
		<td><a Title="Click here to Delete" href="orderstatus.php?a=3&amp;intid=<?php echo $sql[$j]['intid']; ?>" onClick="return confirm('Are you sure to delete this record?');"><img src="images/delete.bmp" border="0"/></a></td></tr>
		
      
	  <?php  } } ?>
	  
      
      <tr>
        
        <td colspan="6" align="center"><?php pagindet_atbotttom_page($div_page_no,$page_no,$req_querystr,$total_db_rec,$row_per_page); ?></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td align="center">&nbsp;</td>
  </tr>
</table>

</body>
</html>
